#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(NULL);
    string s1, s2;
    while(cin >> s1 >> s2){
        int cnt1[32], cnt2[32];
        fill(cnt1, cnt1+32, 0);
        fill(cnt2, cnt2+32, 0);
        for(int i=0; i<s1.size(); i++){
            cnt1[s1[i]-'A']++;
            cnt2[s2[i]-'A']++;
        }
        sort(cnt1, cnt1+32);
        sort(cnt2, cnt2+32);
        bool flg = true;
        for(int i=0; i<32; i++){
            if(cnt1[i] != cnt2[i]){
                flg = false;
                break;
            }
        }
        if(flg) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}
